//
//  BaseViewController.m
//  AgricultureApp
//
//  Created by 米粒 on 16/7/29.
//  Copyright © 2016年 米粒. All rights reserved.
//

#import "BaseViewController.h"
#import "HomeViewController.h"
#import "ViewController.h"
#import "ShopCarViewController.h"
#import "AppendViewController.h"
@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initViewControllers];
    self.tabBar.backgroundColor = [UIColor lightGrayColor];
    
    // 设置数字样式的badge的位置和大小
    [self.tabBar setNumberBadgeMarginTop:2
                       centerMarginRight:30
                     titleHorizonalSpace:8
                      titleVerticalSpace:2];
    // 设置小圆点样式的badge的位置和大小
    [self.tabBar setDotBadgeMarginTop:5
                    centerMarginRight:25
                           sideLength:10];
    
    
    UIViewController *controller1 = self.viewControllers[0];
    UIViewController *controller3 = self.viewControllers[3];
    UIViewController *controller2 = self.viewControllers[1];
    controller2.yp_tabItem.badge=5;
    controller1.yp_tabItem.badge = 888;
    controller3.yp_tabItem.badgeStyle = YPTabItemBadgeStyleDot;
    
    
    
}
- (void)initViewControllers {
    
    HomeViewController *controller1 = [[HomeViewController alloc] init];
  
    UINavigationController *nav1=[[UINavigationController alloc] initWithRootViewController:controller1];
    nav1.yp_tabItemTitle = @"动态宽度";
    nav1.yp_tabItemImage = [UIImage imageNamed:@"tab_message_normal"];
    nav1.yp_tabItemSelectedImage = [UIImage imageNamed:@"tab_message_selected"];
    AppendViewController *controller2 = [[AppendViewController alloc] init];
    
//    UINavigationController *nav2=[[UINavigationController alloc] initWithRootViewController:controller2];
//    
    controller2.yp_tabItemTitle = @"系统Segment";
    controller2.yp_tabItemImage = [UIImage imageNamed:@"tab_me_normal"];
    controller2.yp_tabItemSelectedImage = [UIImage imageNamed:@"tab_me_selected"];
    
    ViewController *controller3 = [[ViewController alloc] init];
    controller3.yp_tabItemTitle = @"普通";
    controller3.yp_tabItemImage = [UIImage imageNamed:@"tab_me_normal"];
    controller3.yp_tabItemSelectedImage = [UIImage imageNamed:@"tab_me_selected"];
    controller3.yp_tabItemImage = [UIImage imageNamed:@"tab_me_normal"];
    controller3.yp_tabItemSelectedImage = [UIImage imageNamed:@"tab_me_selected"];
    
    
    ShopCarViewController *controller4=[[ShopCarViewController alloc] init];
    controller4.yp_tabItemTitle=@"购物车";
    controller4.yp_tabItemImage = [UIImage imageNamed:@"tab_me_normal"];
    controller4.yp_tabItemSelectedImage = [UIImage imageNamed:@"tab_me_selected"];
    self.viewControllers = [NSMutableArray arrayWithObjects:nav1, controller2, controller3,controller4, nil];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    NSLog(@"viewWillAppear");
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
